package models

// AgentWithdrawalLog 代理商提现记录表
type AgentWithdrawalLog struct {
	Model
	AgentId     int     `json:"agent_id" gorm:"comment:'代理商id'"`
	CacheIds    string  `json:"cache_ids" gorm:"comment:'agent_apply_withdrawal_caches id集合'"`
	BeginAmount float64 `json:"total_amount" gorm:"type:decimal(10,2);comment:'税前'"`
	TaxAmount   float64 `json:"tax" gorm:"type:decimal(8,6);comment:'税费'"`
	AfterAmount float64 `json:"amount" gorm:"type:decimal(10,2);comment:'税后'"`
	BankName    string  `json:"bank_name" gorm:"comment:'提现银行名称'"`
	BankNo      string  `json:"bank_no" gorm:"comment:'提现银行卡号'"`
}

// AgentWithdrawalLogCreate 创建记录数据
func AgentWithdrawalLogCreate(log *AgentWithdrawalLog) error {
	return db.Create(&log).Error
}

// WalletWithdrawalRecord 提现记录
func WalletWithdrawalRecord(agentId int) (any, error) {
	var models = make([]*AgentWithdrawalLog, 0)
	if err := db.Model(&AgentWithdrawalLog{}).Where("agent_id = ?", agentId).Scan(&models).Error; err != nil {
		return nil, err
	}
	return models, nil
}
